package com.framework.ACore;

import com.framerock.baselib.Jiami;
import com.framerock.baselib.Rock;

import java.util.Map;

/**
 * 模块条件定义
 * */
public class ModuleWhere {

    /**
     * 创建一个条件模型
     * */
    public static ModuleWhere get()
    {
        return new ModuleWhere();
    }

    private String name = "";


    private String num = "";


    private String where = "";


    private String pnum = "";


    private int islb = 1;


    private int wtype = 0;


    private int sort = 0;

    /**
     * 条件名称[必须]
     * */
    public ModuleWhere setName(String name) {
        this.name = name;
        return this;
    }

    /**
     * 对应条件[必须]
     * */
    public ModuleWhere setWhere(String where) {
        this.where = where;
        return this;
    }

    /**
     * 条件编号[必须]
     * */
    public ModuleWhere setNum(String num) {
        this.num = num;
        return this;
    }

    /**
     * 排序号
     * */
    public ModuleWhere setSort(int sort) {
        this.sort = sort;
        return this;
    }

    /**
     * 是否列表页显示，默认显示
     * */
    public ModuleWhere setIslb(int islb) {
        this.islb = islb;
        return this;
    }

    /**
     * 分组编号
     * */
    public ModuleWhere setPnum(String pnum) {
        this.pnum = pnum;
        return this;
    }

    /**
     * 条件类型 默认0如：FlowWhere.WTYPE_EDIT
     * */
    public ModuleWhere setWtype(int wtype) {
        this.wtype = wtype;
        return this;
    }

    /**
     * 获取定义的模块条件
     * */
    public Map<String, String> getMap()
    {
        if(Rock.isEmpt(this.name) || Rock.isEmpt(this.num) || Rock.isEmpt(this.where))return null;
        Map<String, String> da = Rock.getMap();
        da.put("name", this.name);
        da.put("num", this.num);
        da.put("where", Jiami.base64encode(this.where));
        da.put("pnum", this.pnum);
        da.put("wtype", this.wtype+"");
        da.put("sort", this.sort+"");
        da.put("islb", this.islb+"");
        return da;
    }
}
